<template>
  <el-dialog
    :title="'查看支付凭证详情'"
    :visible.sync="dialogVisible"
    width="100%"
    :fullscreen="true"
    :modal="false"
    modal-append-to-body
    :before-close="handleClose"
    :destroy-on-close="true">
    <div class="xlSeeFrom">

      <div class="tab-item">
        <!--支付凭证-->
        <div>
          <div class="item">
            <p class="tab-title">支付凭证</p>
          </div>
          <div class="tab">
            <el-table
              :header-cell-style="{background:'#F2F6FC',color:'#606266'}"
              :data="paymentData"
              ref="paymentData"
              height="330px"
              tooltip-effect="dark"
              border
              :span-method="objectSpanMethod"
              style="width:100%">
              <el-table-column 
              label="支付凭证编号"
              align="center"
              prop="payment_voucher_id">
              </el-table-column>
              <el-table-column
              label="支付凭证名称"
              align="center"
              prop="payment_voucher_name">
              </el-table-column>
              <el-table-column 
              label="项目名称"
              align="center"
              prop="project_name">
              </el-table-column>
              <el-table-column
              label="报销金额"
              align="center"
              prop="expense_money">
              </el-table-column>
              <el-table-column
              label="工资金额"
              align="center"
              prop="salary_money">
              </el-table-column>
              <el-table-column
              label="总金额"
              align="center"
              prop="total_money">
              </el-table-column>
            </el-table>
          </div>
        </div>

        <!--票据清单-->
        <div>
          <div class="item">
            <p class="tab-title">票据清单</p>
          </div>
          <div class="tab">
            <el-table
              :header-cell-style="{background:'#F2F6FC',color:'#606266'}"
              :data="billData"
              ref="billData"
              height="330px"
              tooltip-effect="dark"
              border
              style="width:100%">
              <el-table-column label="序号" type="index" width="60" align="center"></el-table-column>
              <el-table-column 
              label="票据编号"
              align="center"
              prop="bill_number">
              </el-table-column>
              <el-table-column
              label="员工姓名"
              align="center"
              prop="user_name">
              </el-table-column>
                <el-table-column
                align="center"
                label="操作">
                <template slot-scope="scope">
                    <el-button type="text" size="small" @click="toBillDetail(scope.row.bill_number)">查看详情</el-button>
                </template>
                </el-table-column>
            </el-table>
          </div>
        </div>
      </div>

    </div>
    <span slot="footer" class="dialog-footer">
      <el-button @click="handleClose">关 闭</el-button>
    </span>

    <BillFile ref="billFile"></BillFile>
  </el-dialog>
</template>

<script>
import {seePaymentDetail} from '@/request/other_api'
import BillFile from "../components/billFile";

export default {
components:{
    BillFile,
  },
  data(){
    return {
        dialogVisible:false,
        //支付凭证数据
        paymentData:[],
        //支付凭证表中记录数
        num:0,
        //票据列表
        billData:[],
    }
  },
  mounted () {
    this.level = sessionStorage.getItem('level')
  },
  methods:{
    //支付凭证页面数据
    seePaymentDetail(payment_voucher_id){
        seePaymentDetail({
            payment_voucher_id:payment_voucher_id
        }).then(res =>{
            this.paymentData = res.data
            this.billData = res.billList
            this.num = this.paymentData.length
        })
    },
    objectSpanMethod({ row, column, rowIndex, columnIndex }) {
        if (columnIndex === 0 || columnIndex === 1) {
            if (rowIndex % this.num === 0) {
            return {
                rowspan: this.num,
                colspan: 1
            };
            } else {
            return {
                rowspan: 0,
                colspan: 0
            };
            }
        }
    },
    //关闭窗口
    handleClose (done) {
      this.dialogVisible = false
    },
    //查看报销单详情
    seeReDetail(expense_id){
      this.$refs.seeReForm.seeMyReimbursementDetail(expense_id)
      this.$refs.seeReForm.dialogVisible = true
    },
    toBillDetail(expense_id) {
      this.$refs.billFile.formateData(expense_id)
      this.$refs.billFile.dialogVisible = true
    }
  }
}
</script>

<style lang="less" scoped>
/deep/ .el-form-item__label {
  background-color: #eee;
  text-align: center;
  //width: 121px;
}
/deep/ .el-dialog__header {
  padding: 20px 20px 10px;
  border-bottom: 1px solid #eee;
}
/deep/ .el-dialog__body {
  padding: 10px 20px;
  color: #333;
  font-size: 15px;
  word-break: break-all;
}
.step{
  margin-bottom: 10px;
}
.content{
  margin-top: 10px;
  margin-bottom: 10px;

}
.tab-item{
  width: 100%;
  padding: 10px 0;
  border: 1px solid #eee;

  table{
    width: 100%;
    font-family: verdana,arial,sans-serif;
    font-size:14px;
    color:#333333;
    border-width: 1px;
    border-color: #999999;
    border-collapse: collapse;
  }
  table td{
    border-width: 1px;
    padding: 4px;
    border-style: solid;
    border-color: #999999;
    width: 25%;
  }
  table tr:nth-child(2n+1){
    background-color:#F2F6FC;
    height:50px;
    text-align: center;
  }
  table tr:nth-child(2n){
    background-color: #fff;
    height:50px;
    text-align: center;
  }

.tab-title{
  font-family: SourceHanSansSC;
  font-weight: 700;
  font-size: 20px;
  color: rgb(16, 16, 16);
  font-style: normal;
  letter-spacing: 0px;
  line-height: 30px;
  text-decoration: none;
  padding: 5px 10px;
}
/deep/ .el-date-editor.el-input, .el-date-editor.el-input__inner {
  width: 100%;
 }
}

.tit-header{
    display: flex;
    justify-content: space-between;
    margin: 10px;
}
.search {
    display: flex;
    justify-content: space-between;
    padding-bottom: 20px;
}

</style>
